package smartbooks.exceptions;

import javax.swing.JComponent;
import smartbooks.ui.util.MyBalloonTip;

/**
 *
 * @author Ankit
 */
public class MyExceptionEarlier extends Exception {
    public static MyBalloonTip myBalloonTip = null;
    
    String componentText = new String();
    static String balloonTipText = new String();
    static JComponent jComponent = null;
    
    public MyExceptionEarlier(String componentText, String balloonTipText) {
        this.componentText = componentText;
        MyExceptionEarlier.balloonTipText = balloonTipText;
    }
    
    /**
     * This method will show the Balloontip on the jComponent
     * @param jComponent 
     */
    public void showBalloonTip(JComponent jComponent) {
        MyExceptionEarlier.jComponent = jComponent;
        hideBalloonTip(MyExceptionEarlier.jComponent);
        myBalloonTip = new MyBalloonTip(jComponent, balloonTipText);
    }
    
    /**
     * This method will hide the Balloontip on the jComponent
     * @param jComponent
     */
    public static void hideBalloonTip(JComponent jComponent) {
        if(null!=MyExceptionEarlier.jComponent && null!=jComponent && (MyExceptionEarlier.jComponent).equals(jComponent)) {
            if(null!=myBalloonTip) {
                myBalloonTip.setVisible(false);
            }
        }
    }
    
    /**
     * This method will get the Component text which will determine which Component should show the Balloontip
     * @return component text
     */
    public String getComponentText() {
        return componentText;
    }
    
    /*
     * This method will get the BalloonTip text which will determine the Balloontip on the Component
     * @return BalloonTip text
     */
    public static String getBalloonTipText() {
        return balloonTipText;
    }
}